import java.util.*;
import java.util.regex.*;

/**
 * 在这里给出对类 Player 的描述。
 * 
 * @作者（你的名字）
 * @版本（一个版本号或者一个日期）
 */
public class Player
{
    private int life;
    private int blue;
    private int attack;
    private int defense;
    
    public Player() 
    {
        this.life = 100;
        this.blue = 100;
        this.defense = 200;
        this.attack = 200;
    }
    
    public void walk()
    {
        check();
    }
    
    public void check()
    {
        System.out.println("你当前的状态：");
        System.out.println("生命：" + this.life);
        System.out.println("真气：" + this.blue);
        System.out.println("防御：" + this.defense);
        System.out.println("攻击：" + this.attack);
    }
    
    public boolean isAlive() 
    {
        return this.life > 0;
    }
    
    public boolean isAblue() 
    {
        return this.blue > 0;
    }
    
    public int getLife()
    {
        return this.life;
    }
    
    public int getBlue()
    {
        return this.blue;
    }
    
    public int getAttack()
    {
        return this.attack;
    }
    
    public int getDefense()
    {
        return this.defense;
    }
    
    public void setLife(int hurt)
    {
        this.life += hurt;
    }
    
    public void setBlue(int bl)
    {
        this.blue += bl;
    }
    
    public void useWeapon(Thing thing)
    {
        String pattern = ".*剑.*";
        boolean isMatch = Pattern.matches(pattern, thing.getName());
        if(isMatch) {   
            this.attack += thing.getCans();
        }
        else {
            System.out.println("你修炼了丹药，没有任何加成！");  
        }
        
    }

    public void eat(Thing thing)
    {
        String pattern1 = ".*活血.*";
        boolean isMatch1 = Pattern.matches(pattern1, thing.getName());
        String pattern2 = ".*玄元.*";
        boolean isMatch2 = Pattern.matches(pattern2, thing.getName());
        String pattern3 = ".*子午.*";
        boolean isMatch3 = Pattern.matches(pattern3, thing.getName());
        String pattern4 = ".*赤阳.*";
        boolean isMatch4 = Pattern.matches(pattern4, thing.getName());
        
        if(isMatch1) {
            this.life += thing.getCans();
            if (life > 100) {
                life = 100;
            }
        }
        else if(isMatch2){
            this.blue += thing.getCans();
            if (blue > 100) {
                blue = 100;
            }
        }
        else if(isMatch3){
            this.defense += thing.getCans();
        }
        else if(isMatch4){
            this.attack += thing.getCans();
        }
        else {
            System.out.println("你食用了功法，功法失效，已被销毁！");
        }
    }   
}
